<%@page import="com.xbk.jtable.ui.HtmlUtil"%>
<%@page import="com.xbk.jtable.ui.jTable"%>
<%@page import="com.xbk.platform.DataMap"%>
<%@page import="com.xbk.platform.DaoUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/Include/include.jspf"%>
<%
	DaoUtil du = ConnectionMananger.getDaoUtil();
	String sInterfaceID = request.getParameter("interfaceID");
	
	String jtableData = "";
	DataMap inter = new DataMap(); 
	
	String sSql = "SELECT * FROM DCP_RULE_DEL WHERE OBJECTNO = '"+sInterfaceID+"'";
	jTable jtable = new jTable(du);
	jtable.setKeyCols("RULEID,OBJECTNO");
	jtable.setRelativeTable("DCP_RULE_DEL");
	jtable.setSession(session);
	jtable.setFilter("RULE_TYPE,FIELDS");
	jtable.initBySql(sSql);
	jtable.setHeader(du.getCols(sSql));
	jtableData = jtable.getHtml();
	
	du.close();
%>
</head>
<body>
<!-- top -->
<div id="top">
	<%@include file="/top.jsp" %>
</div>
<!-- content -->
<div class="ml20" id="content">
	<form class="form-inline">
	  <fieldset>
	    <legend>规则定义</legend>
	    <%=HtmlUtil.getSelectOptions("SELECT INTERFACENAME AS K,INTERFACEID AS V FROM DCP_INTERFACE_DEF","选择接口文件", "interfaceID", "interfaceID", sInterfaceID) %>
		<button id="viewFields" class="btn"><i class="icon-search"></i> 查看字段</button>
		<button id="submit" class="btn btn-primary"><i class="icon-pencil icon-white"></i> 引入通用规则</button>
	</fieldset>
	</form>
</div>

<div id="jtableContainer"></div>

</body>
<script type="text/javascript">
$(function() {
	$(function(){
		var jtable = new jDcp.web.Table();
		jtable.parse("<%=jtableData %>");
		jtable.appendTo("jtableContainer");
		jtable.hideCols({col:"INTERFACEID"});
		$(".jtable-container").css("height",(($(window).height() - $(".jtable-container").offset().top) - 25) + "px");
		
		$("#interfaceID").change(function(){
			var interfaceID = $(this).val();
			window.location.replace("RuleDefinde.jsp?interfaceID="+interfaceID+"&rand="+Util.getRandom());
		});
		
		jtable.hideCols({col:"RULEID,OBJECTNO"});
		if(jtable.getRowCount() == 1) jtable.setColValue("OBJECTNO",1,"<%=sInterfaceID %>");
		jtable.hideButton(jDcp.web.Table.BUTTON_DELETE);
		
		$("#viewFields").click(function(){
			var TableName = $("#interfaceID").val();
			window.open("ViewFields.jsp?TableName="+TableName+"&rand="+Util.getRandom(),null,"width:600px;height:250px;top:0;left:0");
		});
	});
});
</script>
</html>